<h1>Listing news</h1>
<%if session[:role] == 0 %>
<table border=1>
  <tr>
  <% for column in News.content_columns %>
    <th><%= column.human_name %></th>
  <% end %>
   <th colspan="3">Action</th>
 
  </tr>
 
	<% for news in @news %>
	  <tr>
	  <% for column in News.content_columns %>
	    <td><%=h news.send(column.name) %></td>
	  <% end %>
	    <td><%= link_to 'Show', :action => 'show', :id => news %></td>
	    <td><%= link_to 'Edit', :action => 'edit', :id => news %></td>
	    <td><%= link_to 'Delete', { :action => 'destroy', :id => news }, :confirm => 'Are you sure?', :method => :post %></td>
	  </tr>
	<% end %>
	
</table>

<%= link_to 'Previous page', { :page => @news_pages.current.previous } if @news_pages.current.previous %>
<%= link_to 'Next page', { :page => @news_pages.current.next } if @news_pages.current.next %> 

<br />

<%= link_to 'Add News', :action => 'new' %>

<%else%>
<table border=1>
	<tr>
  		<% for column in News.content_columns %>
    	<th><%= column.human_name %></th>
  <% end %>
	</tr>

<% for news in @news %>
	  <tr>
	  <% for column in News.content_columns %>
	    <td><%=h news.send(column.name) %></td>
	  <% end %>
	  </tr>
	<% end %>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @news_pages.current.previous } if @news_pages.current.previous %>
<%= link_to 'Next page', { :page => @news_pages.current.next } if @news_pages.current.next %> 

